class CheckFunction {
    static CheckIsDirForSPEC(children_list) {
        for (let i = 0; i < children_list.length; i++) {
            if (children_list[i].label.endsWith(".spec"))
                return true
        }
        return false;
    }

    static CheckKojiLink4CompatibilityReport(link_one) {
        let pattern = /^(?:http(s)?:\/\/)?\d+\.\d+\.\d+\.238\/koji\/taskinfo\?taskID=\d+$/
        return pattern.test(link_one)
    }

    static clone(source) {
        let result;
        if (Object.prototype.toString.call(source) === '[object Object]') {
            result = {};
        } else if (Object.prototype.toString.call(source) === '[object Array]') {
            result = []
        } else {
            return;
        }
        for (let attr in source) {
            if (Object.prototype.toString.call(source[attr]) === '[object Array]' || Object.prototype.toString.call(source[attr]) === '[object Object]') {
                result[attr] = this.clone(source[attr])
            } else {
                result[attr] = source[attr];
            }
        }
        return result;
    }

    static get_format_time(time_str) {
        let date = new Date(time_str);
        let year = date.getFullYear(),
            month = date.getMonth() + 1,
            day = date.getDate()//,
        // hour = date.getHours(),
        // min = date.getMinutes(),
        // sec = date.getSeconds();
        return year + '-' + month + '-' + day // + ' ' + hour + ':' + min + ':' + sec;
    }
}

export default CheckFunction;
